package com.example.controller.pet;

import com.example.pojo.Pet;
import com.example.response.ApiResult;
import com.example.vo.pet.PetExploreVO;
import com.example.service.pet.PetExploreService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Lexin Huang
 */
@Api(tags = "宠物发现模块")
@RestController
public class PetExploreController {


    private final PetExploreService petExploreService;

    public PetExploreController(PetExploreService petExploreService) {
        this.petExploreService = petExploreService;
    }

    @GetMapping("/pets")
    @ApiOperation(("查询同品种的宠物"))
    @ApiImplicitParam(name = "breed", value = "宠物品种", required = true,
            dataTypeClass = String.class, paramType = "query")
    public ApiResult<PetExploreVO> getPetsOfTheSameBreed(@RequestParam("breed") String breed) {
        List<Pet> pets = petExploreService.getSameBreedPets(breed);
        ApiResult<PetExploreVO> response = new ApiResult<>();
        PetExploreVO data = new PetExploreVO();
        data.setPets(pets);
        response.setSuccess(data);
        return response;
    }
}
